<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="../layuiadmin/style/wu.css" media="all">
    <link rel="stylesheet" href="../layuiadmin/style/template.css" media="all">
    <title></title>
    <style>
        .layui-laydate-range {
            width: 547px !important;
        }
    </style>
</head>

<body>
    <div class="layui-fluid">
        <form class="layui-card layui-form" style="padding: 10px;">
            <div class="layui-form-item">
                <label class="layui-form-label">一级分类</label>
                <div class="layui-input-block">
                    <select name="YJFL" cr-monitor="cr-select" lay-filter="selFilter" cr-title="YJFL" cr-value="YJFL" cr-api="Common/GetOneFileTypes" class="layui-select">
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">二级分类</label>
                <div class="layui-input-block">
                    <select name="EJFL" lay-filter="selFilter" cr-monitor="cr-select" cr-title="EJFL" cr-value="EJFL" cr-api="Common/GetTwoFileTypes" class="layui-select">
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">文件分类</label>
                <div class="layui-input-block">
                    <input type="text" name="fileType" lay-verify="required" placeholder="请输入文件分类"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">上传文件数量</label>
                <div class="layui-input-block">
                    <input type="number" name="fileNum" lay-verify="required" placeholder="请输入文件数量"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">文件类型限制</label>
                <div class="layui-input-block">
                    <select name="fileSuffix" lay-filter="fsFilter" cr-monitor="fileSuffix" cr-title="MC" cr-value="ID" cr-api="Common/GetForbidTypes" class="layui-select">
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">开放时间</label>
                    <div class="layui-inline" id="openDate">
                        <div class="layui-input-inline">
                            <input type="text" autocomplete="off" id="startDate" class="layui-input"
                                   placeholder="上传开始时间">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline">
                            <input type="text" autocomplete="off" id="endDate" class="layui-input" placeholder="上传结束时间">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="switch" lay-skin="switch" lay-text="关|开">
                </div>
            </div>
        </form>
    </div>
</body>
<script src="../js/tool/sweetalert.js"></script>
<script src="../layuiadmin/layui/layui.min.js"></script>
<script>
    var $ = '';
    function init(data) {
        layui.config({
            base: '../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['form', 'laydate', 'crSelect', 'index'], function () {
            var form = layui.form, laydate = layui.laydate, crSelect = layui.crSelect;
            $ = layui.$;
            
            crSelect({ // 一级分类、二级分类
                base: "../../",
                monitor: "cr-select",
                isRecursion: true,
                filter: "selFilter",
                success: function () {
                    $("select[name=YJFL]").val(data.YJFL);
                    $("select[name=EJFL]").val(data.EJFL);
                    form.render("select");
                }
            })
            crSelect({ // 文件类型限制
                base: "../../",
                monitor: "fileSuffix",
                success: function () {
                    $("select[name=fileSuffix]").val(data.WJLXXZID);
                    form.render("select");
                }
            })

            // 初始值
            $("input[name=fileType]").val(data.WJFL);
            $("input[name=fileNum]").val(data.SCWJSL);
            $("#startDate").val(data.SCKSSJ);
            $("#endDate").val(data.SCJSSJ);
            data.ZT == 0 ? $("input[name=switch]").attr("checked", true) : "";
            form.render();

            //日期范围
            laydate.render({
                elem: '#openDate'
                , range: ['#startDate', '#endDate']
            });
        });
    }

    function getResult() {
        return {
            YJFL: $("select[name=YJFL]").val(),
            EJFL: $("select[name=EJFL]").val(),
            WJFL: $("input[name=fileType]").val(),
            SCWJSL: $("input[name=fileNum]").val() || 0,
            WJLXXZID: $("select[name=fileSuffix]").val(),
            SCKSSJ: $("#startDate").val(),
            SCJSSJ: $("#endDate").val(),
            ZT: $("input[name=switch]:checked").val() ? 0 : 1
        }
    }
</script>

</html>